package com.zhangkeyou.map.mapweb.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhangkeyou.map.mapweb.domain.entity.Article;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
@Mapper
public interface ArticleMapper extends BaseMapper<Article> {
    @Select("select * from article where userinfoid = #{userinfoId}")
    List<Article> selectArticlelByUserinfoId(String userinfoId);

    @Select("select id,title,intro,createtime from article where userinfoid = #{userinfoId}")
    List<Article> selectArticleListByUserinfoId(String userinfoId);

//    @Insert("insert into  article (id,article,intro,title,userinfoid) values(#{article.id},#{article.article},#{article.intro},#{article.title},#{article.userinfoid})")
    @Insert("insert into  article (id,article,intro,title,userinfoid) values(#{id},#{article},#{intro},#{title},#{userinfoid})")
    int insert(Article article);

    @Update("update article set article = #{article},title=#{title},intro=#{intro} where id =#{id} and userinfoid = #{userinfoid}")
    int updateByIdUserinfoid(Article article);

    @Delete("delete from article where id =#{id} and userinfoid = #{userinfoId}")
    int deleteByIdUserinfoid(@Param("id")String id,@Param("userinfoId")String userinfoId);

    @Select("select * from article where id = #{id}")
    Article getArticleById(String id);

    int updateArticleIdByFileId(@Param("articleId") String articleId,@Param("fileId") String fileId);

}
